﻿using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SaleOnlineSystem.Admin.Controls
{
    public partial class ViewProfile : System.Web.UI.UserControl
    {
        public string user;
        public string email;
        public string fullname;
        public string phone;
        public string address;
        public string avatar;
        public string role;
        public int id;
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Request.QueryString["idaccount"] != null)
                {
                    id = Convert.ToInt32(Request.QueryString["idaccount"]);
                    DataTable dt = DAL.DCollector.DBCollector.Instance.StoredProcedureSelectWhereByID("tbl_Account", "*", "Account_ID", id, "selectwhereid");
                    user = dt.Rows[0]["Account_User"].ToString();
                    email = dt.Rows[0]["Account_Email"].ToString();
                    fullname = dt.Rows[0]["Account_FullName"].ToString();
                    phone = dt.Rows[0]["Account_Phonenumber"].ToString();
                    address = dt.Rows[0]["Account_Address"].ToString();
                    avatar = dt.Rows[0]["Account_Avatar"].ToString();
                    role = dt.Rows[0]["Account_Role"].ToString();
                }
            }
            catch (Exception)
            {
                Response.Redirect("/error.htm");
            }        
        }
        protected void lbtDelete_Click(object sender, EventArgs e)
        {
            try
            {
                int user_id = Convert.ToInt32(Request.QueryString["idaccount"]);
                DAL.DCollector.DBCollector.Instance.StoredProcedureDeleteByRows("tbl_Account", "Account_ID", user_id.ToString());
                Response.Redirect("/Admin/Index.aspx?panel=0&sub=1");
            }
            catch (Exception)
            {
                Response.Redirect("/error.htm");
            }          
        }
    }
}